package com.tsingteng.cosfun.ui.message.fans;

import com.tsingteng.cosfun.bean.FansNotificationBean;
import com.tsingteng.cosfun.bean.FollowBean;
import com.tsingteng.cosfun.callback.RxObserver;
import com.tsingteng.cosfun.mvp.presenter.BasePresenter;
import com.tsingteng.cosfun.ui.message.fans.model.FansListModel;

/**
 * 描述 :
 * 创建人: 肖利.
 * 时间:2018/8/6
 * qq(872179966)
 */

public class FansPresenter extends BasePresenter<FansContract.IFansView> implements FansContract.IFansPresenter{
    FansContract.IFansView view;
    private final FansListModel fansListModel;

    public FansPresenter(){
        fansListModel = new FansListModel();
    }

    @Override
    public void loginFollowFans(String follow_id) {
        view = getView();
        RxObserver<FollowBean> rxObserver = new RxObserver<FollowBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
            }

            @Override
            protected void onSuccess(FollowBean followBean) {
                view.getFollowResult(followBean);
            }
        };

        fansListModel.getFollowNotification(follow_id,rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void loginNoFollow(String follow_id) {
        view = getView();
        RxObserver<FollowBean> rxObserver = new RxObserver<FollowBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
            }

            @Override
            protected void onSuccess(FollowBean followBean) {
                view.getNoFollowResult(followBean);
            }
        };

        fansListModel.getNoFollowNotification(follow_id,rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void loginFansNotification(String user_type, int page) {
        view = getView();
        RxObserver<FansNotificationBean> rxObserver = new RxObserver<FansNotificationBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(FansNotificationBean notificationBean) {
                view.getShowFansData(notificationBean);
            }
        };

        fansListModel.getFansNotification(user_type,page,rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void loginReadNotice(int maxid) {
        view = getView();
        RxObserver<Integer> rxObserver = new RxObserver<Integer>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(Integer integer) {
                view.showReadResult(integer);
            }
        };
        fansListModel.getReadNotification(maxid,rxObserver);
        addDisposable(rxObserver);
    }
}
